/*
package org.example.lost.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.example.filter.WebSecurityCorsFilter;
import org.example.lost.entity.UserInfo;
import org.example.lost.filter.LoginFilter;
import org.example.lost.mapper.UserMapper;
import org.example.lost.service.LostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.cors.CorsUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

*/
/**
 * @Author hxy
 * @Date 2021/3/12 8:55
 * @Version 1.0
 *//*

@Configuration
@EnableWebSecurity

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Autowired
    private UserDetailsService userDetailService;


    @Bean
    public PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailService)
            .passwordEncoder(passwordEncoder());

    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.
                addFilterBefore(new WebSecurityCorsFilter(), ChannelProcessingFilter.class)
                .authorizeRequests()
                .anyRequest().authenticated()
                */
/*.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()*//*

                */
/*.antMatchers(HttpMethod.OPTIONS).permitAll()*//*

                .and()
                .formLogin()
                */
/*.loginPage("http://localhost:8080/#/login")
                .usernameParameter("username")
                .passwordParameter("password")
                .loginProcessingUrl("/core/user")*//*

                .successHandler(new AuthenticationSuccessHandler(){
            @Override
            public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
                String name = authentication.getName();
                */
/*System.out.println(name);*//*

                */
/*UserInfo userInfo = userMapper.selectByPhone("15775024496");*//*

                response.setContentType("application/json;charset=utf-8");
                response.setStatus(200);
                PrintWriter out=response.getWriter();
                Map<String,Object> resultMap = new HashMap<>();
                resultMap.put("code",200);
                resultMap.put("msg","认证通过");
                */
/*if(test == null && !test.equals("")){
                    resultMap.put("data","用户无信息");
                }
                else{
                    resultMap.put("data",test);
                }*//*

                resultMap.put("data",name);

                out.write(new ObjectMapper().writeValueAsString(resultMap));
                out.flush();
                out.close();
            }
        })
                .and()
                .cors();

                http.csrf().disable();
    }
}
*/
